package com.taiyuan.tongcheng.ui.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;

import com.taiyuan.tongcheng.application.AppConfig;
import com.taiyuan.tongcheng.util.SharePreferenceUtil;

public abstract class BaseFragment extends Fragment{
	
	protected  SharePreferenceUtil  spUtil;
	
	protected void initUtil() {
		spUtil=new SharePreferenceUtil(getActivity(), AppConfig.SHARE_NAME);
	}
	
	protected void initView() {
		initUtil();
	}
	

	/** 通过Class跳转界面 **/
	protected void startActivity(Class<?> cls) {
		startActivity(cls, null);
	}

	/** 含有Bundle通过Class跳转界面 **/
	protected void startActivity(Class<?> cls, Bundle bundle) {
		Intent intent = new Intent();
		intent.setClass(getActivity(), cls);
		if (bundle != null) {
			intent.putExtras(bundle);
		}
		startActivity(intent);
	}

	/** 通过Action跳转界面 **/
	protected void startActivity(String action) {
		startActivity(action, null);
	}

	/** 含有Bundle通过Action跳转界面 **/
	protected void startActivity(String action, Bundle bundle) {
		Intent intent = new Intent();
		intent.setAction(action);
		if (bundle != null) {
			intent.putExtras(bundle);
		}
		startActivity(intent);
	}
	

}
